<?php

namespace App\Http\Controllers\Admin\Cocktail;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\Cocktail\Jiweijiu;


class ArticleController extends Controller
{
  //
  public function list(Request $request)
  {
    $all = Jiweijiu::where('id','>',0);

    $name = $request->get('name','');
    if ( $name ) {
      $all = $all->where('name','like','%'. $name .'%');
    }

    $classic = $request->get('classic','-1');
    if ( $classic != -1 ) {
      $all = $all->where('classic',$classic);
    }

    $all = $all->orderBy('id','desc')->paginate(20);

    return view('admin/cocktail/aticle/list')
           ->withclassic($classic)
           ->withname($name)
           ->withall($all);
  }


  // 添加
  public function add()
  {
    return view('admin/cocktail/aticle/add'); 
  }

  // 编辑
  public function edit($id)
  {
    $obj = Jiweijiu::find($id);
    return view('admin/cocktail/aticle/edit')
            ->withobj($obj); 
  }


}
